#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<assert.h>
#include<sys/wait.h>
#include<sys/types.h>
int main()
{

  printf("process is running...\n");
pid_t id=fork();
assert(id!=-1);
if(id==0)
{
  //子进程
sleep(1);
//char* const envp[]={(char*)"MYENV=112233",NULL};
extern char**environ;
putenv((char*)"MYENV=2022886");
execle("./mycom","mycom",NULL,environ);
//execle("./mycom","mycom",NULL,envp);
//  char*const argv_[]={"ls","-a","-l","--color=auto",NULL};
//  execl("./mycom","mycom",NULL);
exit(1);
  //execvp("ls",argv_);
  //execv("/usr/bin/ls",argv_);
  //  execl("/user/bin/ls/"/*传程序路径*/,"ls","-a","-l","--color=auto",NULL/*想怎么执行*/);
//  execlp("ls"/*传程序名*/,"ls","-a","-l","--color=auto",NULL/*想怎么执行*/);
//  //全部的exec函数参数都是以NULL结尾

}
int status=0;
pid_t ret=waitpid(id,&status,0);
if(id>0)
{
  printf("wait success:%d ,sig number: %d,child exit code:%d\n",ret,status&0x7F,(status>>8)&0xFF);
}
  printf("process running done...\n");
  return 0;

}
